#include<bits/stdc++.h>
using namespace std;
#define OK 1
#define ERROR 0
typedef int Status;
typedef struct LNode{
	int data;
	LNode *next;	
}LNode, *LinkList; 
Status Init(LinkList &L)
{
	L = new LNode;
	if(!L) return ERROR;
	L->next = NULL;
	return OK;
}
Status Create(LinkList &L, int n)
{
	LNode *t = L;
	for(int i = 0; i < n; i ++)
	{
		LNode *p = new LNode;
		if(!p) return ERROR;
		cin >> p->data;
		p->next = t->next;
		t->next = p;
		t = p;
	}
	return OK;
}
void DisCreate(LinkList &A, LinkList &B)
{
	/******************Begin***************/
    LNode *pa = A;
	LNode *pb = B;
	while(pa->next)
	{
		pa = pa->next;
		if(!pa->next) break;
		LNode *t = pa->next;
		pa->next = t->next;
		t->next = NULL;
		pb->next = t;
		pb = t; 
	}
    /*****************End*******************/
}

void Show(LinkList L)
{
	LNode *p = L->next;
	while(p)
	{
		cout << p->data << ' ';
		p = p->next;
	}
	cout << endl;
}
int main()
{
	LinkList A, B;
	Init(A);
	Init(B);
	
	int n;
	cin >> n;
	
	Create(A, n);
	
	DisCreate(A, B);
	Show(A);
	Show(B);
	
	return 0;
}